import paramiko
import time

devn_ips = {"AR2":"192.168.99.100" ,"AR1":"10.110.111.17","AR3":"10.110.111.22","AR4":"10.110.111.26","LSW1":"10.110.110.190","LSW2":"10.110.110.125", "LSW3":"10.110.110.126", "LSW4":"10.110.110.254", "LSW5":"10.110.111.14"}
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

for devn, ip in devn_ips.items():
    ssh_client.connect(hostname=ip, username="huawei", password="123456")

    cmd = ssh_client.invoke_shell()

    cmd.send('sys\n')
    cmd.send('sysname  '+devn+'\n')
    cmd.send('q\n')
    cmd.send('save\n')
    time.sleep(1)
    cmd.send('y\n')
    time.sleep(2)
    jieguo1 = cmd.recv(10000).decode("utf-8")
    print(jieguo1)
    ssh_client.close()
